/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import entity.News;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author VANANH
 */
public class NewsModel {
    public static boolean addNewsItem(News n){
        Connection cnn = ConnectionUtil.getConnection();
        try {
            CallableStatement cstm = cnn.prepareCall("{call spInsertNews(?,?,?,?,?)}");
            cstm.setString(1, n.getTitle());
            cstm.setString(2, n.getLink());
            cstm.setString(3, n.getAuthor());
            cstm.setString(4, n.getDescription());
            cstm.setString(5, n.getPubDate());
            cstm.execute();
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(NewsModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }
}
